import request from '@/config/axios'

/** 项目信息 */
export interface OxProject {
  id: number // 项目ID
  projectName: string // 项目名称
  projectPath: string // 项目地址
  remark: string // 项目备注
  categoryList: string[] // 项目分类列表
}

// 项目 API
export const OxProjectApi = {
  // 查询项目分页
  getOxProjectPage: async (params: any) => {
    return await request.get({ url: `/happy/ox-project/page`, params })
  },

  // 查询项目详情
  getOxProject: async (id: number) => {
    return await request.get({ url: `/happy/ox-project/get?id=` + id })
  },

  // 新增项目
  createOxProject: async (data: OxProject) => {
    return await request.post({ url: `/happy/ox-project/create`, data })
  },

  // 修改项目
  updateOxProject: async (data: OxProject) => {
    return await request.put({ url: `/happy/ox-project/update`, data })
  },

  // 删除项目
  deleteOxProject: async (id: number) => {
    return await request.delete({ url: `/happy/ox-project/delete?id=` + id })
  },

  /** 批量删除项目 */
  deleteOxProjectList: async (ids: number[]) => {
    return await request.delete({ url: `/happy/ox-project/delete-list?ids=${ids.join(',')}` })
  },

  // 导出项目 Excel
  exportOxProject: async (params) => {
    return await request.download({ url: `/happy/ox-project/export-excel`, params })
  },
  createRealOxProject: async (data: OxProject) => {
    return await request.post({ url: `/happy/ox-project/createProject`, data })
  },
  trainModel: async (projectId: number) => {
    return await request.post({ url: `/happy/ox-project/trainModel?projectId=` + projectId })
  }
}
